package com.aiju.bean;

import android.text.TextUtils;

import java.io.Serializable;

/**
 * @author: 佐为
 * @date: 2016-11-25 11:55
 * @version: V1.0
 * @Description: 商品
 */
public class Good implements Serializable {

    private String id;          //商品ID
    private String name;        //商品名
    private String code;        //商品条码
    private String goodsTypeId; //商品类型id

    private String goodsTypeName; //商品类型名字
    private String price;       //商品价格
    private String unit;       //商品单位
    private String imageUrl;    //商品图片
    private String createDate;  //商品创建时间
    private String modifyDate;  //商品修改时间

    private String isRelation;   //是否已关联
    private GoodsType goodsType; //商品分类信息

    //业务需要
    private boolean select;     //选中
    private int selectSum;      //选中个数
    private Double selectPrice; //选中的钱数
    private Double weigh;          //重量
    private String currentRelation;   //当前关联状态

    //是否改变关联状态
    public boolean isChange() {
        if (TextUtils.isEmpty(currentRelation)) {
            return false;
        }
        return !isRelation.equals(currentRelation);
    }

    /**
     * 是否关联
     *
     * @return
     */
    public boolean isRelation() {
        return isRelation.equals("1");
    }

    public String getGoodsTypeName() {
        return goodsTypeName;
    }

    public void setGoodsTypeName(String goodsTypeName) {
        this.goodsTypeName = goodsTypeName;
    }

    public String getCurrentRelation() {
        if (TextUtils.isEmpty(currentRelation)) {
            return isRelation;
        }
        return currentRelation;
    }

    public void setCurrentRelation(String currentRelation) {
        this.currentRelation = currentRelation;
    }

    public String getIsRelation() {
        return isRelation;
    }

    public void setIsRelation(String isRelation) {
        this.isRelation = isRelation;
    }

    public Double getWeigh() {
        return weigh;
    }

    public void setWeigh(Double weigh) {
        this.weigh = weigh;
    }

    public boolean isWeighGood() {
        return !TextUtils.isEmpty(unit) && !unit.equals("件");
    }

    public String getUnit() {
        return unit;
    }

    public void setUnit(String unit) {
        this.unit = unit;
    }

    public Double getSelectPrice() {
        return selectSum * Double.valueOf(price);
    }

    public void setSelectPrice(Double selectPrice) {
        this.selectPrice = selectPrice;
    }

    public int getSelectSum() {
        return selectSum;
    }

    public void setSelectSum(int selectSum) {
        this.selectSum = selectSum;
    }

    public GoodsType getGoodsType() {
        return goodsType;
    }

    public void setGoodsType(GoodsType goodsType) {
        this.goodsType = goodsType;
    }

    public boolean isSelect() {
        return select;
    }

    public void setSelect(boolean select) {
        this.select = select;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getCreateDate() {
        return createDate;
    }

    public void setCreateDate(String createDate) {
        this.createDate = createDate;
    }

    public String getGoodsTypeId() {
        return goodsTypeId;
    }

    public int getTypeId() {
        return Integer.valueOf(goodsTypeId);
    }

    public void setGoodsTypeId(String goodsTypeId) {
        this.goodsTypeId = goodsTypeId;
    }

    public String getId() {
        return id;
    }

    public int getIntId() {
        return Integer.valueOf(id);
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getImageUrl() {
        return imageUrl;
    }

    public void setImageUrl(String imageUrl) {
        this.imageUrl = imageUrl;
    }

    public String getModifyDate() {
        return modifyDate;
    }

    public void setModifyDate(String modifyDate) {
        this.modifyDate = modifyDate;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPrice() {
        return price;
    }

    public void setPrice(String price) {
        this.price = price;
    }

}
